<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: specials.php 502 2014-01-31 15:50:06Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 502 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2014-01-31 15:50:06 +0000 (Fri, 31 Jan 2014) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

if(!$product->isProduct()) {
	$box_smarty = new smarty;
	$box_smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');
	$box_smarty->assign('html_tpl_path', CURRENT_TEMPLATE.'/html');
	
	$list_data = get_list_data('specials_box');
	
	$check = $db->db_query("SELECT specials_id FROM ".TABLE_SPECIALS." WHERE status = '1'");
	
	if($check->_numOfRows) {
		$special_products = $db->db_query_limit("SELECT
													p.products_id,
													pd.products_name,
													p.products_price,
													p.products_tax_class_id,
													p.products_image,
													s.expires_date,
													p.products_vpe,
													p.products_vpe_status,
													p.products_vpe_value
												FROM 
													".TABLE_PRODUCTS." p,
													".TABLE_PRODUCTS_DESCRIPTION." pd,
													".TABLE_SPECIALS." s
												WHERE
													p.products_status = '1'
												AND
													p.products_id = s.products_id
												AND
													pd.products_id = s.products_id
												AND
													pd.language_id = '".$_SESSION['languages_id']."'
												AND
													s.status = '1'
													".$product->fsk18().$product->groupCheck()."
												ORDER BY
													s.specials_date_added DESC, RAND()", $list_data['box_count']);

		$rows = 0;
		$box_specials_content = array();
		while(!$special_products->EOF) { $rows ++;
			$box_specials_content[] = $product->buildDataArray($special_products->fields, 'thumbnail', $list_data, $rows, 172);
			$special_products->MoveNext();
		}
		$box_smarty->assign('box_specials_content', $box_specials_content);
		if($special_products->_numOfRows > 1 && $list_data['box_effect'] != 'none')	{
			$get[] = 'sb='.$list_data['box_effect'];
			$get[] = 'sbd='.$list_data['effect_direction'];
		}
		
		$box_smarty->assign('SPECIALS_LINK', href_link(FILENAME_SPECIALS));

		$box_smarty->assign('language', $_SESSION['language']);
	
		 if(!CacheCheck()) {
			$box_smarty->caching = false;
			$box_content = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_specials.html');
		} else {
			$box_smarty->caching = true;
			$box_smarty->cache_lifetime = CACHE_LIFETIME;
			$box_smarty->cache_modified_check = CACHE_CHECK;
			$cache_id = 'box_specials_'.$_SESSION['language'].$random_product->fields["products_id"].$_SESSION['customers_status']['customers_status_name'];
			$box_content = $box_smarty->fetch(CURRENT_TEMPLATE.'/boxes/box_specials.html', $cache_id);
		}
	}
}